/*
 * FolderHandler.java
 *
 * Created on 14 September 2006, 11:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package fasea.index.filehandler;

import java.io.File;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;

/**
 *
 * @author gvasil
 */
class FolderHandler extends FileHandler {
    
    protected Document getTypedDocument(File file) throws FileHandlerException {
        org.apache.lucene.document.Document doc = createDefaultLuceneDocument(file);
        String path = null, filename = null;
        try {
            path = file.getCanonicalPath();
            filename = path.substring(path.lastIndexOf(File.separatorChar) + 1);
            
            doc.add(new Field("content", filename, Field.Store.NO,
                    Field.Index.ANALYZED, Field.TermVector.YES));

        } catch (IOException e) {
            throw new FileHandlerException(e.getMessage());
        }
        
        return doc;
    }
}
